package gogs_hook

import "jihulab.com/linksaas/proto-gen-go/events/events_gogs"

type DeleteHook struct {
	Ref        string      `json:"ref"`
	RefType    string      `json:"ref_type"`
	PusherType string      `json:"pusher_type"`
	Repo       *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

func (item *DeleteHook) ToProtoBuf() *events_gogs.DeleteEvent {
	ret := &events_gogs.DeleteEvent{
		Ref:        item.Ref,
		RefType:    item.RefType,
		PusherType: item.PusherType,
		Repo:       []*events_gogs.Repository{},
		Sender:     []*events_gogs.User{},
	}
	if item.Repo != nil {
		ret.Repo = append(ret.Repo, item.Repo.ToProtoBuf())
	}
	if item.Sender != nil {
		ret.Sender = append(ret.Sender, item.Sender.ToProtoBuf())
	}
	return ret
}
